<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<?php
	echo $this->Html->css('addition-style');
	echo $this->Html->script('more');
?>
<div id="main-form">
	<h1>Edit Ledger Entry</h1>
      <?php echo $this->Form->create(); ?>
        <div class="top-group">
          <div class="form-group">
            <label for="">Date</label>
            <?php echo $this->Form->input('entry_date', array('id' => 'datepicker', 'label' => false, 'type' => 'text', 'class' => 'form-control', 'value' => $eDate )); ?>
          </div>
        </div>
        <div class="left-group">
          <div class="form-group">
            <label for="">Description</label>
            <?php
            echo $this->Form->textarea('details', array('class' => 'form-control bigger'));
            ?>
            <label for="">Reason</label>
            <?php
            echo $this->Form->textarea('detail', array('label' => false, 'class' => 'form-control', 'required' => 'required'));
			?>
          </div>
        </div>
        <div class="mid-group">
          <div class="form-group">
            <label for="">amount</label>
            <div class="amount-control">
              <span class="negative">-US$ (</span>
              <span class="negative">)</span>
              <span class="positive show">US$</span>
              <?php echo $this->Form->input('amount', array('label' => false, 'type' => 'text', 'class' => 'form-control bigger', 'id' => 'amount', 'onkeyup'=> 'ThousandSeparate(this)' )); ?>
              <script language="JavaScript">
              ThousandSeparate(document.getElementById("amount"));
				
				<?php if ($dType == 'D') { ?>
				$('#amount').toggleClass('red');
				$('.negative').addClass('show');
				$('.positive').removeClass('show');
				<?php } ?>
              </script>
            </div>
          </div>
          <div class="form-group debcre">
            <label>Debit</label>
            <input type="radio" <?php if ($dType == 'D') { echo "checked"; } ?> name="data[Ledger][type]" id="debit" value="D"/>
            <span>Debit</span>
            <label>Credit</label>
            <input type="radio" <?php if ($dType == 'C') { echo "checked"; } ?> name="data[Ledger][type]" id="credit" value="C"/>
            <span>Credit</span>
          </div>
          <?php
          	$user = $this->Session->read('User');
          	if ( $user['User']['access_level'] < 2 ) {
          		echo "<div class='form-group half'>";
          		echo "<label for=''>Division</label>";
				echo $this->Form->input('division_id', array('label' => false,'div' => 'select-input'));
				echo "</div>";
          		echo "<div class='form-group half'>";
          		echo "<label for=''>Department</label>";
				echo $this->Form->input('department_id', array('label' => false,'div' => 'select-input'));
				echo "</div>";
			}
          ?>
          <div class="form-group">
            <label for="">category</label>
            <?php
            
            echo $this->Form->input('category_id', array('label' => false,'div' => 'select-input'));

            ?>
          </div>
        </div>
        <div class="right-group">
          <div class="form-group">
            <button type="submit" class="btn btn-primary" value="save">save</button>
            <!-- a href="#reset" class="btn">reset</a -->
            <?php
            echo $this->Html->link('Reset', array('controller' => 'ledgers', 'action' => 'index'), array("class" => "btn"));
			?>
          </div>
        </div>
      </form>
      <?php
		if ($this->Form->isFieldError('entry_date')) {
			echo $this->Form->error('entry_date');
		}
      ?>
    </div>
    
<?php

/* 
 * Old Add
 */
 
 /*

	echo $this->Form->create();
		
	echo $this->Form->input('entry_date');
	echo $this->Form->input('details');
	echo $this->Form->input('amount', array(
		'type' => 'text'));
	
	$type_options = array('D' => 'Debit', 'C' => 'Credit');
			
	echo $this->Form->input('type', array('options' => $type_options, 'default' => 'C'));
	
	// superuser or organization admin
	if ( $this->Session->read('User')['User']['organization_id'] < 2 ) {
		echo $this->Form->input('division_id');
		echo $this->Form->input('department_id');
	}
	
	echo $this->Form->input('category_id');
	//echo $this->Form->label('AuditTrail.detail', 'State Reason', array('class'=>'mandatory'));
	echo $this->Form->input('detail', array('label' => 'Reason', 'required' => 'required'));
	
	echo $this->Form->end( 'save' );

  */

?>
